<template>
  <a-dropdown placement="bottomRight">
    <div class="header-option" style="cursor: pointer;opacity:0.9">

      <a-icon id="setting-top" :component="require('@/assets/icon/Fleet_Status_Filter_Setting.svg')" />
      <span class="name" />
    </div>

    <div slot="overlay" class="log-out-box" :class="['option-menu']">
      <div class="option-menu-in">
        <a-form-model layout="vertical">
          <a-form-model-item label="历史航段点倒序：">

            <a-switch size="small" :checked="historicalSegmentPointReversed" @change="changeHSPR">
              <a-icon slot="checkedChildren" type="check" style="font-size:10px" />
            </a-switch>
          </a-form-model-item>
          <a-form-model-item label="页面新窗口打开：">
            <a-switch size="small" :checked="openTypeF" @change="changeOpenType">
              <a-icon slot="checkedChildren" type="check" style="font-size:10px" />
            </a-switch>
          </a-form-model-item>
          <a-form-model-item label="航班详情页面查看：">
            <a-switch size="small" :checked="fleetStatusClickEvent" @change="changeFleetStatusClickEvent">
              <a-icon slot="checkedChildren" type="check" style="font-size:10px" />
            </a-switch>
          </a-form-model-item>
        </a-form-model>

      </div>

      <!-- <a-menu-item>
        <a-icon type="user" />
        <span>个人中心</span>
      </a-menu-item>
      <a-menu-item>
        <a-icon type="setting" />
        <span>设置</span>
      </a-menu-item>
      <a-menu-divider /> -->
      <!-- <a-menu-item @click="logout">
        <a-icon style="margin-right: 8px;" type="poweroff" />
        <span>退出登录</span>
      </a-menu-item> -->
    </div>
  </a-dropdown>
</template>

<script>
import { mapMutations, mapState } from 'vuex';

export default {
  name: 'HeaderAvatar',

  computed: {
    ...mapState('setting', ['historicalSegmentPointReversed', 'openType', 'fleetStatusClickEvent']),
    openTypeF() {
      return this.openType !== '_self';
    }
  },
  methods: {
    ...mapMutations('setting', ['setState']),
    changeHSPR(v) {
      localStorage.setItem('hspr', v);
      this.setState({ key: 'historicalSegmentPointReversed', payload: v });
    },
    changeOpenType(v) {
      const typeO = v ? '_blank' : '_self';
      localStorage.setItem('openType', typeO);
      this.setState({ key: 'openType', payload: typeO });
    },
    changeFleetStatusClickEvent(v) {
      localStorage.setItem('fleetStatusClickEvent', v);
      this.setState({ key: 'fleetStatusClickEvent', payload: v });
    }
  }
};
</script>

<style lang="less">
@import './Option.less';

</style>
